import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { CrossGuildWarChooseForTopData } from "../data/CrossGuildWarChooseForTopData";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { DisplayUtil } from "../../../../common/DisplayUtil";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { Language } from "../../../../../extend/language/Language";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class CrossGuildWarChooseForTop8N4N2N1Render
    
    export  class CrossGuildWarChooseForTop8N4N2N1Render extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            this._spBg = new Object /* flash.display.Sprite */();
            this._btn.configEventListener(flash.events.MouseEvent.CLICK, this.chooseReqHandler);
            return;
        }

        /* internal  */chooseReqHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossGuildWarSelectForTopXReq, this._myData));
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            this._myData = arg1 as CrossGuildWarChooseForTopData;
            if (this._myData.isSelectedByOurGuild) 
            {
                this._spBg.addChild(ObjCreate.createBg(0, 0, 172, 52, this, ImagesConst.CrossGuildWar_SelectSelf));
            }
            else if (this._myData.isSelected || this._myData.isSelfGuild) 
            {
                this._spBg.addChild(ObjCreate.createBg(0, 0, 172, 52, this, ImagesConst.CrossGuildWar_Selected));
            }
            else 
            {
                this._spBg.addChild(ObjCreate.createBg(0, 0, 172, 52, this, ImagesConst.CrossGuildWar_SelectNormal));
            }
            if (this._myData.isSelected || this._myData.isSelfGuild || this._myData.isSelectedByOurGuild) 
            {
                DisplayUtil.removeMe(this._btn);
            }
            else 
            {
                this.addChild(this._btn);
            }
            if (this._myData.isSelected) 
            {
                this._txtServerName.filters = [FilterConst.colorFilter];
                this._txtGuildName.filters = [FilterConst.colorFilter];
            }
            else 
            {
                this._txtServerName.filters = [FilterConst.glowFilter];
                this._txtGuildName.filters = [FilterConst.glowFilter];
            }
            if (this._myData.isSelectedByOurGuild) 
            {
                this._txtAlreadyChoose.visible = true;
            }
            else 
            {
                this._txtAlreadyChoose.visible = false;
            }
            this._txtServerName.text = this._myData.serverName;
            this._txtGuildName.text = this._myData.guildName;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this.addChild(this._spBg);
            this._txtServerName = ObjCreate.createGTextField("", 8, 7, 150, 20, this);
            this._txtGuildName = ObjCreate.createGTextField("", 8, 27, 150, 20, this);
            this._btn = ObjCreate.createGButton(Language.getString(80566), 123, 14, 45, 22, this);
            this._txtAlreadyChoose = ObjCreate.createGTextField(Language.getString(44361), 123, 14, 60, 20, this);
            this._txtAlreadyChoose.textColor = 16776960;
            return;
        }

        /* internal */ /* var */_txtServerName: GTextFiled;

        /* internal */ /* var */_txtGuildName: GTextFiled;

        /* internal */ /* var */_btn: GButton;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_spBg: Object /* flash.display.Sprite */;

        /* internal */ /* var */_myData: CrossGuildWarChooseForTopData;

        /* internal */ /* var */_txtAlreadyChoose: GTextFiled;
    }
